<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1,minimum-scale=1.0,maximum-scale=1.0,user-scalable=no">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <title>filmMobile</title>
</head>

<body>
    <!-- 基本要求，点击一个小li删去
    input点击后添加内容 -->
    <div id="app">
        <input type="text" v-model='todo.id'>
        <input type="text" v-model='todo.name'>
        <input type="text" v-model='todo.thing'>
        <input type="submit" @click='addSub'>
        <ul>
            <li v-for='(lis,index) in lists' :key='index' @click='remove(index)'>
                {{lis.name}}{{lis.thing}}
            </li>
        </ul>
    </div>
</body>
<script src="https://cdn.jsdelivr.net/npm/vue@2.5.16/dist/vue.js"></script>
<script>
    new Vue({
        el: '#app',
        data() {
            return {
                lists: [{
                    id: 1,
                    name: 'zby',
                    thing: '打篮球'
                }, {
                    id: 2,
                    name: 'yds',
                    thing: '踢足球'
                }, {
                    id: 3,
                    name: 'gch',
                    thing: '打排球'
                }],
                todo: {
                    id: '',
                    name: '',
                    thing: ''
                }
            }
        },
        methods: {
            remove(index) {
                this.lists = this.lists.filter((item, idx) => idx !== index);
            },
            addSub(e) {
                e.preventDefault();
                const todo = Object.assign({}, this.todo);
                this.lists.push(todo);
                this.todo.id = '';
                this.todo.name = '';
                this.todo.thing = ''
            }
        }
    })
</script>

</html>